/**
 * Created by THINK on 2017/7/6.
 */
$(function() {

    //执行开机动画
    loadingAnimation();

    try{
        if($.cookie('loadindex') == "1"){
            $(".header").show();
            // showWindows();
        }
    }catch(e){
        console.log(e.name + " : " + e.message);
    }

    function showWindows()
    {
        $(".header").show();
        try{
            $.cookie('loadindex', '1', { expires:1});
        }catch(e){
            console.log(e.name + " : " + e.message);
        }
        $('#mainDiv').removeClass('index-page-main').addClass('default');
        $('.yindaodonghua').remove();
        $('.yindaodonghua-bg').remove();
    }

    if("undefined" != typeof(currentPath) && currentPath == "index")
    {
        $(".header").hide();
        $("#footer").hide();
        $("#mainDiv").css("margin-top","-150px")

    }

    //代办
    $('.show-to-do-list').on({
        'mouseover': function() {
            $(this).addClass('on').find('>.to-do-list').slideDown(350);

        },
        'mouseleave': function() {
            $(this).removeClass('on').find('>.to-do-list').stop().removeAttr('style')
        }
    });
});

//开机动画
function loadingAnimation() {
    var loadimg = ['bdqnFoledr/statics/img/bg1.jpg', 'bdqnFoledr/statics/img/bg2.jpg', 'bdqnFoledr/statics/img/bg3.jpg'];
    var random = Math.floor(Math.random() * loadimg.length);
    //alert(random);
    $('#m-yingdao-img').attr('src', loadimg[random] + '?time=' + Math.random());
    $('.f-clearauto').on('click', function() {
        $('#mainDiv').removeAttr("style");
        $("#footer").show();
        $(".header").show();

        try{
            $.cookie('loadindex', '1', { expires:1});
        }catch(e){
            console.log(e.name + " : " + e.message);
        }

        $('#mainDiv').removeClass('index-page-main').addClass('default');

        $('.loading-animation').fadeOut(1500, function() {
            $(this).remove();
            $('.loading-animation-bg').fadeOut(1500, function() {
                $(this).remove()
            })
        })
    });
}
